package com.book.oauth.server.user.entity;

import com.book.common.api.entity.CurrentUser;
import com.book.oauth.server.role.entity.AuthRole;
import com.google.common.collect.Lists;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.List;

/**
 * Description：
 * @Author： leo.xiong
 * @CreateDate： 2019/10/11 11:56
 * @Email： leo.xiong@suyun360.com
 * Version：1.0
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class AuthUser extends CurrentUser implements UserDetails, Serializable {
    private static final long serialVersionUID = 4698015209118127104L;

    private boolean rememberMe = false;

    private String host;

    private boolean encryptPwd = true;

    private String captcha;

    private String password;

    private boolean mobileLogin;

    private List<AuthRole> authorities = Lists.newArrayList();

    @Override
    public List<AuthRole> getAuthorities() {
        return authorities;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
